<template>
  <div id="app">
    <div>珠峰今年多少岁： {{age}}岁</div>
    <div>我的年龄是：{{myAge}}岁</div>
    <div>a模块的年龄是{{this.$store.state.a.age}}岁</div>
    <div>b模块的年龄是{{this.$store.state.b.age}}岁</div>
    <button @click="$store.commit('a/changeAge', 5)">同步更新age</button>
    <button @click="$store.commit('b/changeAge', 5)">异步更新age</button>
  </div>
</template>

<script>
import { mapState, mapGetters } from './vuex/index';
// import { mapState, mapGetters } from 'vuex';

export default {
  name: 'App',
  computed: {
    ...mapState(['age']),
    ...mapGetters(['myAge']),
  },
  mounted() {
    console.log(this.$store);
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
